package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.mapper.TravelStatusMapper;
import com.ruoyi.system.domain.TravelStatus;
import com.ruoyi.system.service.ITravelStatusService;

/**
 * 司机出行接单状态管理Service业务层处理
 *
 * @author trip
 * @date 2024-09-11
 */
@Service
public class TravelStatusServiceImpl extends ServiceImpl<TravelStatusMapper, TravelStatus> implements ITravelStatusService {

    @Autowired
    private TravelStatusMapper travelStatusMapper;

    /**
     * 查询司机出行接单状态管理
     *
     * @param travelStatusId 司机出行接单状态管理主键
     * @return 司机出行接单状态管理
     */
    @Override
    public TravelStatus selectTravelStatusByTravelStatusId(Long travelStatusId) {
        return travelStatusMapper.selectTravelStatusByTravelStatusId(travelStatusId);
    }

    /**
     * 查询司机出行接单状态管理列表
     *
     * @param travelStatus 司机出行接单状态管理
     * @return 司机出行接单状态管理
     */
    @Override
    public List<TravelStatus> selectTravelStatusList(TravelStatus travelStatus) {
        return travelStatusMapper.selectTravelStatusList(travelStatus);
    }

    /**
     * 新增司机出行接单状态管理
     *
     * @param travelStatus 司机出行接单状态管理
     * @return 结果
     */
    @Override
    public int insertTravelStatus(TravelStatus travelStatus) {
        travelStatus.setCreateTime(DateUtils.getNowDate());
        return travelStatusMapper.insertTravelStatus(travelStatus);
    }

    /**
     * 修改司机出行接单状态管理
     *
     * @param travelStatus 司机出行接单状态管理
     * @return 结果
     */
    @Override
    public int updateTravelStatus(TravelStatus travelStatus) {
        travelStatus.setUpdateTime(DateUtils.getNowDate());
        return travelStatusMapper.updateTravelStatus(travelStatus);
    }

    /**
     * 批量删除司机出行接单状态管理
     *
     * @param travelStatusIds 需要删除的司机出行接单状态管理主键
     * @return 结果
     */
    @Override
    public int deleteTravelStatusByTravelStatusIds(Long[] travelStatusIds) {

        LambdaUpdateWrapper<TravelStatus> wrapper;
        for (Long id : travelStatusIds) {
            wrapper = Wrappers.lambdaUpdate(TravelStatus.class)
                    .eq(TravelStatus::getTravelStatusId, id)
                    .set(TravelStatus::getDelFlag, "1");
            super.update(new TravelStatus(), wrapper);
        }
        return 1;
    }

    /**
     * 删除司机出行接单状态管理信息
     *
     * @param travelStatusId 司机出行接单状态管理主键
     * @return 结果
     */
    @Override
    public int deleteTravelStatusByTravelStatusId(Long travelStatusId) {
        return travelStatusMapper.deleteTravelStatusByTravelStatusId(travelStatusId);
    }
}